using System.Configuration;
using System.Data.Common;
using System.Data.SQLite;

using Microsoft.Practices.EnterpriseLibrary.Data;

using EnterpriseLibraryContrib.Data.SQLite;

#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
#endif

namespace EnterpriseLibraryContrib.Data.SQLite.Tests
{
    [TestClass]
    public class SQLiteDatabaseFixture
    {
        [TestMethod]
        public void ConnectionTest()
        {
            DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource());
            ConnectionStringSettings data = view.GetConnectionStringSettings("SQLiteNorthwind");
            SQLiteDatabase sqliteDatabase = new SQLiteDatabase(data.ConnectionString);

            DbConnection connection = sqliteDatabase.CreateConnection();
            Assert.IsNotNull(connection);
            Assert.IsTrue(connection is SQLiteConnection);
            connection.Open();
            DbCommand cmd = sqliteDatabase.GetSqlStringCommand("Select * from Region");
            cmd.CommandTimeout = 60;
            Assert.AreEqual(cmd.CommandTimeout, 60);
        }
    } 
}